﻿using AnyCAD.Foundation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rapid.CAX.Model
{
    public class SolidSchema : ElementSchema
    {
        public SolidSchema()
            : base(nameof(SolidSchema))
        {
            this.SetTitle("实体");
            this.SetCategory("Solid");
            SetIcon("/Rapid.Common.Res;component/Image/SectionBar.png");
        }

        public override Element OnCreateInstance()
        {
            return new ShapeInstance();
        }

        static public ElementId CreateA(String name, TopoShape shape, Document doc)
        {
            var instance = ShapeInstance.Cast(ElementSchemaManager.Instance().CreateInstance(nameof(SolidSchema), name, doc));
            instance.SetDeflection(0.02);
            instance.SetShape(shape);

            return instance.GetId();
        }

        static public ElementId Create(String name, TopoShape shape, Document doc)
        {
            var undo = new UndoTransaction(doc);
            undo.Start(name);

            var id = CreateA(name, shape, doc);

            undo.Commit();

            return id;
        }
    }
}
